<#assign ckeditor=JspTaglibs["/WEB-INF/tld/ckeditor.tld"]>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="imagetoolbar" content="no" />
	<title></title>
	<script type="text/javascript" src="${base}/admin/js/jquery-1.7.min.js"></script>
	<script type="text/javascript" src="${base}/admin/js/jquery.validate.js"></script>
	<link rel="stylesheet" href="${base}/admin/css/style_workSpace.css" />
	<link href="${base}/admin/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
	<script type="text/javascript" src="${base}/admin/uploadify/swfobject.js"></script>
	<script type="text/javascript" src="${base}/admin/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
</head>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F8F9FA;
}
-->
	a{text-decoration:none;color:bule;}
	.error{color:red;}
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
<body>
<form id="formCategory" action="realStore_save.action" method="POST"  enctype ="multipart/form-data" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">店铺管理</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
              <tr>
                <td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;当前位置：添加实体店铺</td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">店铺名称：</td>
                <td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                <td width="40%" height="30" bgcolor="#f2f2f2">
                	<input name="realStore.name" type="text" id="realStore.name" size="30" />
                	<input  name="brandId" id="brandId" type="hidden" value="${brandId!''}" />
                 	<span class="error"> * </span>
                   <span class="verror"></span>
                   </td>
                <td width="*" height="30" bgcolor="#f2f2f2" class="left_txt">&nbsp;</td>
              </tr>
             
               <tr>
                <td height="30" align="right" class="left_txt2">店面图片： </td>
                <td>&nbsp;</td>
                <td height="30">
                	<input type="hidden" id="filePath" name="filePath"  size="61" />
	                <div id="listed-files" style="border:solid 1px gray; width:400px; height:60px; overflow: auto;"></div>
                </td>
                <td height="30" class="left_txt"><input type="file" id="uploadify" name="uploadify" /></td>
              </tr>
              
               <tr>
                <td height="30" align="right" class="left_txt2">内景图片： </td>
                <td>&nbsp;</td>
                <td height="30">
                	<input type="hidden" id="inFilePath" name="inFilePath" size="61" />
	                <div id="listed-files-two" style="border:solid 1px gray; width:400px; height:60px; overflow: auto;"></div>
                </td>
                <td height="30" class="left_txt"><input type="file" id="uploadifytwo" name="uploadifytwo" /></td>
              </tr>
                <tr>
                <td height="30" colsapn="4" align="right" bgcolor="#F7F8F9" class="left_txt2">描述：</td>
              </tr>
             <tr>
                <td height="30" colspan="4">
                <textarea id="branDescription" name="realStore.description" style="width:400px; height:50px;" >${(realStore.description)!''}</textarea>
                 <@ckeditor.replace replace="branDescription" basePath="${base}/ckeditor/" >
                </@ckeditor.replace>
                </td>
              </tr>
               
            </table></td>
          </tr>
        </table>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="35%" height="30" align="right"><input type="button" onclick="formSubmit()"  value="保存" name="B1" /></td>
              <td width="6%" height="30" align="right">&nbsp;</td>
              <td width="58%" height="30"><input type="reset" value="取消" name="B12" /></td>
            </tr>
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</form>
    
    
<script type="text/javascript">

$(document).ready(function(){
		$("#formCategory").validate({
			errorPlacement:function(error,element) {  
				element.parent().find(".verror").html(error);
  			},
			rules : {
				"realStore.name" : {
					required:true,
					maxlength:50
				}
			},
			messages : {
				"realStore.name" : {
					required:"请输入分类名称",
					maxlength:"分类名称长度不能超过50个汉字"
				}
			}
		});
		
		$('#uploadify').uploadify({
		    'uploader'	  		: '${base}/admin/uploadify/uploadify.swf',//是组件自带的flash，用于打开选取本地文件的按钮 
		    'script'    		: '${stack.findValue("@com.wooophone.mpyeah.util.SystemUtil@adminUploadFileAction")}',//处理上传的路径，这里使用Struts2是XXX.action 
		    'cancelImg' 		: '${base}/admin/uploadify/cancel.png',
		    'buttonImg'			: '${base}/admin/uploadify/select.png',//选择文件的按扭图片
		    'folder'  		  	: '${stack.findValue("@com.wooophone.mpyeah.util.SystemUtil@adminUploadFilePath")}',//上传到服务器目录，格式要求：/项目名/文件夹
		    'fileDataName'	 	: 'uploadify',//和input的name属性值保持一致就好，Struts2就能处理了
		    'auto'         		: false,//是否选取文件后自动上传
		    'multi'   			: true,//是否支持多文件上传
		    'simUploadLimit'	: 1,//每次最大上传文件数
		    'queueID'        	: 'listed-files', //自定义的显示区域
		    'sizeLimit'   		: 1024*1024,//最大限制100M
		    'displayData'    	: 'speed',//有speed和percentage两种，一个显示速度，一个显示完成百分比 
		    'fileDesc'       	: '支持格式:jpg/gif/jpeg/png/bmp/zip/war/ppt/pptx.', //如果配置了以下的'fileExt'属性，那么这个属性是必须的 
		    'fileExt'        	: '*.jpg;*.gif;*.jpeg;*.png;*.bmp;*.ppt;*.pptx;*.war;*.zip;*.iso',//允许的格式
		    'onComplete'     	: uploadCompleteOne, //上传完成
		    "onError"           : uploadFail, //当传错误
		  });
		  
		  $('#uploadifytwo').uploadify({
		    'uploader'	  		: '${base}/admin/uploadify/uploadify.swf',//是组件自带的flash，用于打开选取本地文件的按钮 
		    'script'    		: 'http://images.wooophone.com/upload/uploadify.action',//处理上传的路径，这里使用Struts2是XXX.action 
		    'cancelImg' 		: '${base}/admin/uploadify/cancel.png',
		    'buttonImg'			: '${base}/admin/uploadify/select.png',//选择文件的按扭图片
		    'folder'  		  	: '/mpyeah/images',//上传到服务器目录，格式要求：/项目名/文件夹
		    'fileDataName'	 	: 'uploadify',//和input的name属性值保持一致就好，Struts2就能处理了
		    'auto'         		: false,//是否选取文件后自动上传
		    'multi'   			: true,//是否支持多文件上传
		    'simUploadLimit'	: 1,//每次最大上传文件数
		    'queueID'        	: 'listed-files-two', //自定义的显示区域
		    'sizeLimit'   		: 1024*1024,//最大限制100M
		    'displayData'    	: 'speed',//有speed和percentage两种，一个显示速度，一个显示完成百分比 
		    'fileDesc'       	: '支持格式:jpg/gif/jpeg/png/bmp/zip/war/ppt/pptx.', //如果配置了以下的'fileExt'属性，那么这个属性是必须的 
		    'fileExt'        	: '*.jpg;*.gif;*.jpeg;*.png;*.bmp;*.ppt;*.pptx;*.war;*.zip;*.iso',//允许的格式
		    'onComplete'     	: uploadCompleteTwo, //上传完成
		    "onError"           : uploadFail, //当传错误
		  });
	});
	
	function showResult(){//删除显示的上传成功结果
	   	$("#result").html("");
	}
	function uploadFileOne(){//上传文件
	   	$('#uploadify').uploadifyUpload();
	}
	function uploadFileTwo(){//上传文件
	   	$('#uploadifytwo').uploadifyUpload();
	}
	function clearFile(){//清空所有上传队列
		$('#uploadify').uploadifyClearQueue();
	}
	function upload(){
		$("#file_upload").uploadifyUpload();
	}
	var uploadCompleteOne = function(event, queueID, fileObj, response, data){
		var pathObj=eval("("+response+")");
		var path=pathObj.path;
		document.getElementById("filePath").value=path;
		//判断上传控件2 是否有文件列表
		var $fileItemObjTwo=$("#listed-files-two");
		if($fileItemObjTwo.children(".uploadifyQueueItem").html()==null){
				$("#formCategory").submit();
			}else{
				uploadFileTwo();
		}
	}
	
	var uploadCompleteTwo = function(event, queueID, fileObj, response, data){
		var pathObj=eval("("+response+")");
		var path=pathObj.path;
		document.getElementById("inFilePath").value=path;
		$("#formCategory").submit();
	}
	var uploadFail = function(event, queueID, fileObj){
		$("#result").html($("#result").html()+"<p />"+fileObj.name+"---->"+"fild");
	}
	var uploadCancel = function(event, queueID, fileObj){
		$("#result").html($("#result").html()+"<p />"+fileObj.name+"---->"+"cancel");
	}
	
	function formSubmit(){
		//uploadifyQueueItem   如果文件选择控件 中有文件列表 则先上传文件  再提交表单  否则 直接提交 表单
		var $fileItemObj=$("#listed-files");
		var $fileItemObjTwo=$("#listed-files-two");
		if($fileItemObj.children(".uploadifyQueueItem").html()==null){
			if($fileItemObjTwo.children(".uploadifyQueueItem").html()==null){
				$("#formCategory").submit();
			}else{
				uploadFileTwo();
			}
		}else{
			uploadFileOne();
		}
	}
	
</script>
    
</body>
</html>